package com.application.Adapter;

import java.util.ArrayList;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

import com.application.Activity.R;
import com.application.Adapter.DetailLearningAdapter.ViewDetailLearning;

public class DetailLearningAdapter extends ArrayAdapter<ViewDetailLearning> {

	private final Context context;
	private final ArrayList<ViewDetailLearning> detaillearning_content;
	int resource;

	/**
	 * @param context :truyen activity hien hanh
	 * @param textViewResourceId : truyen id widget
	 * @param subject : truyen mang du lieu can load len custom view group
	 */
	public DetailLearningAdapter(Context context, int textViewResourceId,ArrayList<ViewDetailLearning> part)
	{
		super(context,textViewResourceId,part);
		this.context = context;
		resource = textViewResourceId;
		detaillearning_content = part;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		final ViewDetailLearning listpart = detaillearning_content.get(position);
		
		View rowView = convertView;
		if (rowView == null) {
			LayoutInflater inflater = (LayoutInflater) this.getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);;
			rowView = inflater.inflate(R.layout.listrow_listpart,null, true);
		}
		if(listpart !=null)
		{				
			TextView title = (TextView) rowView.findViewById(R.id.part_tv_title);
			TextView content = (TextView) rowView.findViewById(R.id.part_tv_content);
				
			title.setText(listpart.view_title);
			content.setText(listpart.view_content);
		}
        return rowView;
	}	
	
	
	public static class ViewDetailLearning{
		public String view_title;
		public String view_content;
		
		public ViewDetailLearning(String s1,String s2)
		{
			this.view_title = s1;
			this.view_content = s2;
		}		
	}
}
